<template>
  <div class="comment">
    <van-nav-bar left-text="评论" left-arrow @click-left="$router.go(-1)" />
    <van-loading size="24px" v-show="idLoading">加载中...</van-loading>
    <div class="box">
      <div class="img-item">
        <van-image
          width="64px"
          height="64px"
          fit="contain"
          :src="songList.al.picUrl"
          @click="$router.go(-1)"
        />
        <div class="songName">
          <p>{{ songList.al.name }}</p>
          <p class="col">{{ songList.ar[0].name }}</p>
        </div>
      </div>
      <div class="line"></div>
      <h4 class="jingcai">精彩评论</h4>
      <div
        class="commen"
        v-show="showComment"
        v-for="(item, index) in commentList"
        :key="index"
      >
        <div class="info">
          <img :src="item.user.avatarUrl" alt="" />
          <div class="nikeName">
            <span>{{ item.user.nickname }}</span>
            <div>
              <p>{{ item.content }}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import { getComment } from './comment'
export default {
  name: 'comment',
  computed: {
    ...mapState(['songList'])
  },
  data () {
    return {
      commentList: [], //热门评论列表
      showComment: false,
      idLoading: true,
      hotList: []
    }
  },
  async created () {
    let res = await getComment({ id: this.$store.state.commentId })
    console.log(res)
    this.commentList = res.data.hotComments
    this.hotList = res.data.comments
    setTimeout(() => {
      this.showComment = true
      this.idLoading = false
    }, 2000)
  }
}
</script>

<style scoped>
.comment {
  position: relative;
}
.box {
  margin-left: 15px;
}
.img-item {
  display: flex;
}
.img-item p {
  margin-left: 10px;
  font-size: 12px;
}
.songName .col {
  color: cornflowerblue;
}
.line {
  height: 5px;
  background-color: #f5f5f5;
}
.jingcai {
  font-size: 12px;
  font-weight: 400;
}
.commen img {
  height: 24px;
  width: 24px;
  border-radius: 50%;
}
.info {
  display: flex;
  width: 90%;
}
.info {
  font-size: 12px;
}
.nikeName {
  margin-left: 5px;
}
.van-loading {
  position: absolute;
  top: 180px;
  left: 110px;
  font-size: 20px;
  z-index: 50;
}
</style>
